func = {}

func.px = (css) ->
    parseInt (css)

func.offset = (selector) ->
    f = $(selector).offset()
    console.log f
    return

func.checkIntersecion = (s, b) ->
    js      = $(s)
    jb      = $(b)
    jst     = $('.user_profile_stack')
    small   = {}
    big     = {}
    stack   = {}

    # GET WIDTH
    small.width = js.width()
    small.width_2 = Math.floor small.width/2
    big.width = jb.width()
    stack.width = jst.width()

    small.height = js.height()
    small.height_2 = Math.floor small.height/2
    big.height = jb.height()
    stack.height = jst.height()

    small.top = js.offset().top
    big.top = jb.offset().top
    stack.top = jst.offset().top

    small.left = js.offset().left
    big.left = jb.offset().left
    stack.left = jst.offset().left

    # CHECK IN
    if (big.left <= small.left) and (big.left + big.width >= small.left + small.width) and
    (small.top >= big.top) and (small.top + small.height <= big.top + big.height)
        true

    # CASE 1 TOP
    if ((small.top + small.height - big.top > small.height_2) and (small.top + small.height > big.top) and (small.top < big.top)) or
    ((small.top < big.top + big.height) and (small.top + small.height > big.top + big.height) and ((small.top + small.height) - (big.top + big.height) < small.height_2)) or
    ((big.top < small.top) and (big.top + big.height > small.top + small.height))
        if ((small.left + small.width_2 < big.left + big.width) and (small.left < big.left + big.width) and (small.left + small.width > big.left + big.width)) or
        ((small.left + small.width > big.left) and (small.left < big.left)) or
        ((big.left < small.left) and (small.left + small.width < big.left + big.width))
            true

    false

func.swap = (id1, id2) ->
    element1 = document.getElementById id1
    element2 = document.getElementById id2
    clonedElement1 = element1.cloneNode true
    clonedElement2 = element2.cloneNode true
    element2.parentNode.replaceChild clonedElement1, element2
    element1.parentNode.replaceChild clonedElement2, element1

    clonedElement1